package at.fhj.itm10.eventgallery;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.ProgressBar;
import android.widget.TextView;
import at.fhj.itm10.eventgallery.controller.EventJoinerAsync;

public class LoadingActivity extends Activity {
	
	private TextView subTitle;
	private ProgressBar progressBar;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_loading);
        
        subTitle = (TextView) findViewById(R.id.load_subTitle);
        progressBar = (ProgressBar) findViewById(R.id.load_progressBar);
        
        
        
//        ConnectivityManager connManager = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
//        NetworkInfo mWifi = connManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
//
//        if (mWifi.isConnected()) {
//            //if wifi connected
//        }
//
//        ConnectivityManager connManager1 = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
//        NetworkInfo mMobile = connManager1.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
//
//        if (mMobile.isConnected()) {
//            //if internet connected
//        }      
        
        
        
        
        EventJoinerAsync joiner = null;
      	joiner = new EventJoinerAsync(subTitle, progressBar);
    	Log.d("own", getIntent().getExtras().getString("EVENT_CODE"));
    	joiner.execute(getIntent().getExtras().getString("EVENT_CODE"));
    	
		Intent resultIntent = LoadingActivity.this.getIntent();
		setResult(Activity.RESULT_OK, resultIntent);
		finish();

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_loading, menu);
        return true;
    }
}
